import React from 'react';

import './index.less';

// 页面配置信息配置
import pageConfig from './config';
import ApproveDetail from 'uap/common/components/ApproveDetail';
import ApprovalTrans from 'uap/common/components/approvalTrans';
import {getAppPageConfig, handleHash} from '../../../../hrpub/common/utils/utils';
import CardView from '../../../../hrpub/common/components/card-view';
import WpsModal from '../../../../hrpub/common/components/wpsPreModel';
const {
    components: {
        AddPage, 
        OfferContentModal, 
        OrgSituationModal,
        BatchAddModal,
        FileManager,
        HeaderMiddleContent,
        Layout,
        Pagination,
        EmptyPage,
        MainTableOperator
    },
    actions,
    methods: {
        createPage,
        high,
        render
    }
} = pageConfig;

const {Header, Left, Content} = Layout;
// const {
//     // ApproveDetail,
//     ApprovalTrans} = high;

const HomePage = render({
    actions: actions
})(({props, action, state}) => {

    const {emp, button, editTable, search} = props;

    return (
        <div>
            <Choose>
                <When condition={emp.page === 'main'}>
                    <Layout 
                        className="employing-page"
                    >
                        <Header
                            showButtons={!!emp.orgValue}
                            showOrgRefer={emp.showOrgRefer}
                            orgReferOptions={{
                                getOrgData: action.btnAct.changeOrg,
                                orgVal: emp.orgValue,
                                showEmpty:emp.widget?true:false
                            }}
                            buttonOptions={{
                                area: 'head',
                                onButtonClick: action.btnAct.headerClick
                            }}
                            button={button}
                        >
                            <div>
                                <If condition={!!emp.orgValue}>
                                    <HeaderMiddleContent />
                                </If>
                            </div>
                        </Header>
                        <Content
                            className="pageContent"
                            style={{
                                height: emp.pageHeight - 25
                            }}
                        >
                            <div className="employing-main-table-wrapper">
                                <If condition={!!emp.orgValue || emp.widget}>
                                    <div id="mainTable">
                                        {editTable.createEditTable('list', {
                                            showCheck: true,
                                            onSelectedAll: action.tableAct.selectAll,
                                            onRowDoubleClick: action.tableAct.doubleClick,
                                            // height: emp.pageHeight - 128,
                                            adaptionHeight: true,
                                            onSelected: action.tableAct.selectOneRow
                                        })}
                                    </div>
                                    <div
                                        style={{
                                            marginTop: '10px',
                                            paddingRight: '20px'
                                        }}
                                    >
                                        <If condition={emp.pageInfo.total > 0}>
                                            <Pagination
                                                current={emp.pageInfo.pageIndex}
                                                pageSize={emp.pageInfo.pageSize}
                                                total={emp.pageInfo.total}
                                                showSizeChanger={true}
                                                showQuickJumper={true}
                                                onChange={action.pageAct.turnPage}
                                                onShowSizeChange={action.pageAct.changePageSize}
                                            />
                                        </If>
                                        
                                    </div>
                                    <Else/>
                                        <EmptyPage
                                            text={emp.language['gx6008-000084']}
                                        />
                                </If>
                            </div>
                        </Content>
                        <div style={{
                            display: 'none'
                        }}>
                            {search.NCCreateSearch('querybill', {
                                clickSearchBtn: action.searchAct.toSearch
                            })}
                        </div>
                    </Layout>
                </When>
                <When condition={emp.page === 'add' || emp.page === 'edit'}>
                    <AddPage 
                        {...props}
                        fileManager={action.btnAct.fileManager}
                        btnAct={action.btnAct}
                    />
                </When>
            </Choose>
            <If condition={emp.approveModalVisible}>
                <ApproveDetail
                    show={true}
                    close={action.mainAct.closeModal('approveModalVisible')}
                    billtype={emp.approveBillType}
                    billid={emp.approveBillId}
                />
            </If>
            {/* <If condition = {emp.rowOperator}>
                <MainTableOperator
                    {...props}
                    language={emp.language}
                    isApprFlow={emp.isApprFlow}
                    onClick={action.tableAct.rowClickHandle}
                    close = {action.tableAct.closeOperator}
                    record={emp.rowsDetail.record}
                    index={emp.rowsDetail.index}
                    button={button}
                />
            </If> */}
            <OfferContentModal 
                visible={emp.offerContentModalVisible}
                language={emp.language}
                content={emp.offerModalContent}
                closeModal={action.offerAct.closeOfferModal}
                sendOffer={action.offerAct.sendOffer}
            />
            <OrgSituationModal 
                {...props}
            />
            <BatchAddModal
                {...props}
            />
            {/* <CardView
                {...props}
                onRef={ref => action.btnAct.cardViewRef = ref}
            /> */}
             <WpsModal
                    {...props}
                    onRef ={ref => action.btnAct.wpsview = ref}
                    appcode={'60092010'}
                    pk_org={emp.orgValue}
                   
                />
            <If condition={emp.fileManagerModalVisible}>
                <FileManager
                    language={emp.language}
                    billId={emp.fileManagerBillId}
                    onClose={action.mainAct.closeModal('fileManagerModalVisible')}
                />
            </If>
            {emp.compositedisplay ? <ApprovalTrans
                    title={emp.language['10140CUSTPF-000034']}/* 国际化处理： 指派*/
                    data={emp.compositedata}
                    display={emp.compositedisplay}
                    getResult={action.rowAct.getResult}
                    cancel={action.rowAct.turnOff}
                /> : ""}
        </div>
    );
})

export default createPage({
    billinfo: [{
        billtype: 'form', 
        pagecode: '60092010p', 
        headcode: 'card'
    }]
})(handleHash('2019', 'c=60092010&p=60092010p')(HomePage));